<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@include file="../common/init.jsp"%>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>处理中，请稍后....</title>

    <script type="text/javascript" src="${ctx}/static/js/jquery-1.8.3.min.js"></script>
    <script type="text/javascript">
        var ctx = '${ctx}';
        var redirectUrl = '${redirectUrl}';
        var result = '${result}';
        var orderId = '${orderId}';
        var loop =0;
        var time;

        function notify(){
            window.location.href=ctx+redirectUrl;
        }

        function loopNotify(){
            $.ajax({
                url:ctx+"/pay/getOrderResult.shtml?"+(new Date()).getTime(),
                async:false,
                type:"GET",
                dataType:"JSON",
                data:{orderId:orderId}
            }).done(function(data){
                result = data.result;
            });
        }

        function timedCount(){
            loop=loop+1;
            time = setTimeout("timedCount()", 3000);
            if (result == '2' || result == '1'){//失败 /成功
                clearTimeout(time);
                notify();
            }else if(loop > 5){//超时
                clearTimeout(time);
                window.location.href=ctx+"/00100/express/timeout.shtml?orderId="+orderId;
            }else{
                loopNotify();
            }
        }

        $(function() {
            if (result == '1') {
                notify();
            } else {
                timedCount();
            }
        });
    </script>
</head>
<body>
<div style="border:1px solid #aec4e2;background:#eef3f9;text-align: center;font-weight: bold;top:30%;left:30%;position: absolute;width:500px;height:70px;">
    <div style="font-size: 14px;top:35%;left:20%;position:absolute;">
        <img alt="" src="${ctx}/static/img/loading.gif" width="24px;" height="24px;"/>&nbsp;&nbsp;&nbsp;
        付款处理中，请稍后....
    </div>
</div>
</body>
</html>
